﻿
<%@ Page language="c#" Inherits="Mysoft.Crm.Application.Pages.Tools.FormEditor.Dialogs.Tab" CodeBehind="Mysoft.Crm.Application.Pages.Tools.dll" %>
<html>
<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"/>
<title><%= title %></title>
<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
<link rel="stylesheet" type="text/css" href="/_common/styles/select.css">
<link rel="stylesheet" type="text/css" href="/_nav/tabs.css">
<link rel="stylesheet" type="text/css" href="/Tools/FormEditor/Styles/dialogs.css">
<script language="javascript" src="/_controls/settings.aspx"></script>
<script language="javascript" src="/_common/scripts/global.js"></script>
<script language="javascript" src="/Tools/FormEditor/Scripts/objects.js"></script>
<script language="javascript" src="/Tools/FormEditor/Scripts/dialogs.js"></script>
<script language="javascript">

	var _oFormXml;
	
	
	function window.onload()
	{
		_oFormXml = window.dialogArguments.FormXml;

		var oTab = window.dialogArguments.Tab;

		crmDialog.TabName.value			= oTab.TabName;
		crmDialog.TabName.defaultValue	= oTab.TabName;

		var oLabels	= oTab.Labels;

		if (oLabels)
		{
			crmDialog.Description.value			= oLabels[0].Description;
			crmDialog.Description.defaultValue	= oLabels[0].Description;
		}
	}


	function Ok()
	{
		crmDialog.Description.value = Trim(crmDialog.Description.value);

		var sTabDesc = crmDialog.Description.value;

		crmDialog.TabName.value = sTabDesc.toLowerCase();

		if (sTabDesc.length == 0)
		{
			//alert( "Enter a tab name." );
			alert("键入一个标签名！");
			crmDialog.Description.select();

			return;
		}

		if (sTabDesc.indexOf('"') > -1 || sTabDesc.indexOf("'") > -1 || sTabDesc.indexOf("\\") > -1 || sTabDesc.indexOf("&") > -1 || sTabDesc.indexOf('|') > -1 || sTabDesc.indexOf('<') > -1)
		{
			//alert( "Tab names cannot contain any of the following characters:" + " \" ' \\ & | <");
			alert("标签名不能包含下列字符："+ " \" ' \\ & | <");

			crmDialog.Description.select();

			return;
		}

		if (crmDialog.TabName.value != crmDialog.TabName.defaultValue)
		{
			if (_oFormXml.selectSingleNode("/entity/form/tabs/tab[@name = '" + crmDialog.TabName.value + "']"))
			{
				//alert( "The tab name you entered is already in use." );
				alert("您键入的标签名已经被使用！");
				crmDialog.Description.select();

				return;
			}
		}

		window.returnValue	= new TabObj(
								crmDialog.TabName.value,
								new Array(new LocalizedObj(crmDialog.Description.value, ORG_LANGUAGE_CODE))
							);

		window.close();
	}

</script>
</head>
<body>
	<form name="crmDialog">
		<input type="hidden" name="TabName">
		<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
			<tr>
				<td class="header">
					<div class="header"><%= title %></div>
					<div class="headerdesc"><%= description %></div>
				</td>
			</tr>
			<tr>
				<td class="main">
					<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
						<col width="50"><col>
						<tr>
							<td class="req">标签名</td>
							<td><input name="Description" type="text"></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td class="buttons">
					<button id="btnDialogOk" onclick="Ok();">确定</button>
					&nbsp;
					<button id="btnDialogCancel" onclick="Cancel();">取消</button>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
